//
//  SQLManager.m
//  joke
//
//  Created by liwei on 15/12/13.
//  Copyright © 2015年 liwei. All rights reserved.
//

#import "SQLManager.h"
#import "FMDB.h"
#import "unistd.h"

@interface SQLManager () {
    SqlHelper *_sqlHelper;
}

@end

@implementation SQLManager

+ (SQLManager *)sharedInstance {
    static SQLManager *sharedInstance = nil;

    static dispatch_once_t predicate; dispatch_once(&predicate, ^{
        sharedInstance = [[self alloc] init];
    });

    return sharedInstance;

}

- (instancetype)init {
    if (self = [super init]) {
        NSString *doc = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
        
        NSLog(@"--------documentPath:%@", doc);
        
        NSString *fileName = [doc stringByAppendingPathComponent:@"LuQu.sqlite"];
        
//        NSLog(@"%@", fileName);
        
        _sqlHelper = [[SqlHelper alloc] initWithDBFilePath:fileName AndSQLPlist:[[NSBundle mainBundle] pathForResource:@"DBFile" ofType:@"plist"]];
        
        self.dbQueue = _sqlHelper.dbQueue;
    }
    return self;
}

@end
